package com.jic.market.mapper.coupon;

import com.jic.market.entity.coupon.CouponTrigger;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 优惠券商品关联表
 *
 * @author : seven
 * @version : v1.0.0
 * @email : 774329481@qq.com
 * @since : 2020-03-15 08:30:01
 */
@Repository
public interface CouponTriggerMapper {

    Long insert(CouponTrigger couponTrigger);

    Long delete(String promotionId);

    Long update(CouponTrigger couponTrigger);

    CouponTrigger queryByPrimaryKey(Long id);

    List<CouponTrigger> query(CouponTrigger couponTrigger);

    List<CouponTrigger> queryPage(@Param("startIndex") int startIndex, @Param("limit") int limit, @Param("couponTrigger") CouponTrigger couponTrigger);

    long queryPageCount(CouponTrigger couponTrigger);

    @Select("select trigger_id from market_coupon_trigger where promotion_id=#{promotionId} and trigger_type=#{triggerType} and delete_flag='0'")
    List<String> queryTriggerByPromotionIdAndTriggerType(@Param("promotionId")String promotionId,
                                                         @Param("triggerType")String triggerType);

    @Select("select * from market_coupon_trigger where promotion_id=#{promotionId} and delete_flag='0'")
    List<CouponTrigger> queryByPromotionId(@Param("promotionId")String promotionId);

    List<String> queryTriggerByPromotionIdAndNoTriggerType(@Param("promotionId")String promotionId);

    int insertBatch(@Param("items")List<CouponTrigger> triggerList);
}